<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }

        li {
            list-style-type: none;
        }

        .box {
            height: 400px;
            /* background-color: aqua; */
            display: flex;
        }

        .main {
            width: 400px;
            height: 400px;
            position: relative;
            /* background-color: olivedrab; */
        }

        .main img {
            width: 100%;
            height: 100%;
        }

        .small {
            width: 68px;
            height: 400px;
            /* background-color: pink; */
            margin-left: 12px;
        }

        .small li {
            width: 68px;
            height: 68px;
            border: 2px solid transparent;
            margin-bottom: 15px;
        }

        .small li img {
            width: 100%;
            height: 100%;
        }

        .big {
            width: 400px;
            height: 400px;
            /* background-color: gold; */
            background-image: url(./1.jpg);
            background-size: 800px 800px;
            display: none;
        }

        .mc {
            pointer-events: none;
            width: 200px;
            height: 200px;
            background-color: rgba(0, 0, 0, 0.587);
            position: absolute;
            top: 0;
            left: 0;
            display: none;
        }
    </style>
</head>

<body>
    <div class="box">

        <div class="main">
            <img src="./1.jpg" alt="">
            <div class="mc"></div>
        </div>
        <div class="small">
            <ul>
                <li><img src="./1.jpg" alt=""></li>
                <li><img src="./2.jpg" alt=""></li>
                <li><img src="./3.jpg" alt=""></li>
                <li><img src="./4.jpg" alt=""></li>
                <li><img src="./5.jpg" alt=""></li>
            </ul>
        </div>
        <div class="big">

        </div>
    </div>
</body>

</html>
<script>
    var s_img = document.querySelectorAll('.small img')
    var m_img = document.querySelector('.main img')
    var big = document.querySelector('.big')
    var mc = document.querySelector('.mc')
    for (var i = 0; i < s_img.length; i++) {
        s_img[i].onmouseover = function () {
            this.style.border = '2px solid blue';
            m_img.src = this.src;
        }
        s_img[i].onmouseout = function () {
            this.style.border = '2px solid transparent';
        }
    }
    m_img.onmouseenter = function () {
        big.style.display = 'block'
        big.style.backgroundImage = `url(${this.src})`
    }
    m_img.onmouseleave = function () {
        big.style.display = 'none'
        mc.style.display = 'none'
    }
    m_img.onmousemove = function (e) {
        mc.style.display = 'block'
        var x = e.pageX - 100;
        var y = e.pageY - 100;
        var maxX = 200;
        var maxY = 200;
        x = x < 0 ? 0 : x;
        x = x > maxX ? maxX : x
         // 控制x坐标y坐标 的最小值
        y = y < 0 ? 0 : y;
        y = y > maxY ? maxY : y
        mc.style.top = y + 'px'
        mc.style.left = x + 'px'
        big.style.backgroundPosition = `${-2*x}px ${-2*y}px`
    }
</script>